import { IsString, IsNumber, IsBoolean, IsDate, IsOptional, IsEnum, IsArray } from 'class-validator';
import { ApiProperty, OmitType, IntersectionType } from '@nestjs/swagger';
import { PagingDto } from 'src/common/dto/index';
import { CharEnum } from 'src/common/enum/index';
import { Type } from 'class-transformer';

export class BaseTemplateDto {
  @ApiProperty({ required: false, description: '主键ID' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  id?: number;

  @ApiProperty({ required: false, description: '模板名称' })
  @IsOptional()
  @IsString()
  name?: string;

  @ApiProperty({ required: false, description: '模板编码' })
  @IsOptional()
  @IsString()
  templateCode?: string;

  @ApiProperty({ required: false, description: '签名名称' })
  @IsOptional()
  @IsString()
  signName?: string;

  @ApiProperty({ enum: CharEnum, required: false, description: '删除标志' })
  @IsOptional()
  @IsString()
  delFlag?: string;

  @ApiProperty({ required: false, description: '创建时间' })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  createTime?: Array<string>;

  @ApiProperty({ required: false, description: '更新时间' })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  updateTime?: Array<string>;
}

export class CreateTemplateDto extends OmitType(BaseTemplateDto, ['id', 'delFlag', 'createTime']) {}

export class UpdateTemplateDto extends OmitType(BaseTemplateDto, ['delFlag', 'createTime']) {}

export class QueryTemplateDto extends IntersectionType(BaseTemplateDto, PagingDto) {}

export class ListTemplateDto extends OmitType(BaseTemplateDto, ['delFlag', 'createTime', 'updateTime']) {}
